﻿@model EnetaMvc.Web.Models.EventListModel
@using System.Configuration
@using EnetaMvc.Infrastructure
@using EnetaMvc.ApplicationServices.Dto
@{
    Layout = "~/Views/Shared/_EventLayout.cshtml";
    ViewBag.Title = @Resources.EnetaMvc.Events;
}
<div id="content" class="calendar">
    <span class="content-top">&nbsp;</span>
	<div class="content-main">

        <div class="calendar-head">
	        <div class="calendar-head-main">
		        <h2><a href="@Request.RawUrl">@Resources.EnetaMvc.Events</a></h2>
                @if(User.IsInRole("Administrator"))
                {
                    <a href="@Url.Action("Create","Events")" style="float:right;margin-right:20px;">@Resources.EnetaMvc.AddEvent</a>
                }
                @Html.GetPager(Model.Events, Url.Content("~/events/"))
	        </div>
	        <a class="event-banner" href="#"><img alt="image" src="@Url.Content("~/images/img-50.jpg")" width="633" height="98" /></a>
	        @*<div class="slide-block">
		        <div class="calendar-title"> <a href="javascript:;" class="toggle">@Resources.EnetaMvc.EventCalendar</a> </div>
		        <div id="block">
			        <div>
				        <div class="calendar-main"> <img alt="image" src="images/img-38.gif" width="633" height="172" /> </div>
			        </div>
		        </div>
	        </div>*@
        </div>
        <div class="events-area">
            @foreach (var eventItem in Model.Events.Results)
            {
                var firstEventSuffix = "";
                if (Model.Events.CurrentPage == 1 && eventItem.Id == Model.Events.Results[0].Id)
                {
                    firstEventSuffix = "first-event";
                }
                var attendingSuffix = "";
                if (Model.ContainsEventId(eventItem.Id))
                {
                    attendingSuffix = "attending";
                }
	            <div class="event @firstEventSuffix @attendingSuffix">
		            <div class="date-box">
			            <div class="month"> <span>@eventItem.StartDate.ToString("MMM")</span> </div>
			            <div class="date-top">
				            <div class="date"> <strong>@eventItem.StartDate.Day</strong> </div>
			            </div>                        
		            </div>
		            <div class="event-txt">
			            <h3><a href="@Url.Content("~/Events/Details/" + eventItem.Id)">@eventItem.Title</a>
                            @if (eventItem.CommentsCount > 0)
                            { 
                                <span>(@eventItem.CommentsCount)</span>
                            }
			            </h3>
                        @if (User.IsInRole("Administrator"))
                        { 
                            <a href="@Url.Action("Delete", "Events", new { id = eventItem.Id })" style="float:right">@Resources.EnetaMvc.Delete</a> 
                            <a href="@Url.Action("Edit", "Events", new { id = eventItem.Id })" style="float:right; margin-right:5px;">@Resources.EnetaMvc.Edit</a> 
                            
                        }
			            <ul class="event-panel">
                            @Html.DisplayDateRange(eventItem.StartDate, eventItem.EndDate)
				            <li class="place">@eventItem.VenueName</li>
			            </ul>
			            <p>@eventItem.Abstract
                        <a class="more-info" href="@Url.Content("~/Events/Details/" + eventItem.Id)">@Resources.EnetaMvc.ReadMore</a></p>
			            <div class="event-foot-panel"> 
                            @if(eventItem.AttendeesCount > 0)
                            {
                                <span class="user">@string.Format(Resources.EnetaMvc.EventAttendeesTextInList,eventItem.AttendeesCount)</span>
                            }
                            @if (eventItem.RegistrationEndDate < DateTime.Now)
                            { 
                                <span class="full">@Resources.EnetaMvc.EventRegistrationIsOver</span>
                            }
                            @if(eventItem.RegistrationEndDate >= DateTime.Now)
                            {
				                <!--form action="#"-->
                                    if(!Model.ContainsEventId(eventItem.Id))
                                    {
					                    <fieldset>
                                        @if(eventItem.HasRealEvent)
                                        {
					                        <div class="registreeru">
                                                <form action="@Url.Action("RegisterToEvent", new { id = eventItem.Id })" method="get">
                                                <input type="hidden" name="realEvent" value="true" />
						                        <input type="submit" value="@Resources.EnetaMvc.RegisterToEventButtonTitle" />
                                                </form>
					                        </div>
                                        }
                                        @if(eventItem.HasVirtualEvent)
                                        {
					                        <div class="registreeru webcast">
                                                <form action="@Url.Action("RegisterToEvent", new { id = eventItem.Id })" method="get">
                                                <input type="hidden" name="realEvent" value="false" />
						                        <input type="submit" value="@Resources.EnetaMvc.RegisterToVirtualEventButtonTitle" />
                                                </form>
					                        </div>
                                        }
					                    </fieldset>
                                    }
                                    else 
                                    {
                                        <fieldset>
					                    <span class="attending"><img width="16" height="16" src="@Html.GetProfileUrl((long)Session["UserId"], 16)" alt="@Session["UserName"]" />@string.Format(Resources.EnetaMvc.YouAreRegisteredToEventLabel, Session["UserName"])</span>
					                    <div class="lisa-kalendrise">
                                            <form action="@Url.Action("vCard", new { id = eventItem.Id })" method="get">
						                    <input type="submit" value="@Resources.EnetaMvc.AddEventToCalendarButtonTitle" />
                                            </form>
					                    </div>
					                    <div class="loobu-btn">
                                            <form action="@Url.Action("UnregisterFromEvent", new { id = eventItem.Id })" method="get">
						                    <input type="submit" value="@Resources.EnetaMvc.Cancel" title="@Resources.EnetaMvc.CancelEventButtonTooltip" />
                                            </form>
					                    </div>
					                    </fieldset>                                    
                                    }
				                <!--/form-->
                            }
			            </div>
		            </div>
	            </div>        
            }
        </div>
        <div class="blogs-menu">
	        <ul>
		        <li><a href="@Url.Content("~/")">@ConfigurationManager.AppSettings["PortalName"]</a></li>
		        <li><a href="@Url.Content("~/events/")">@Resources.EnetaMvc.Events</a></li>
	        </ul>
	        @Html.GetPager(Model.Events, Url.Content("~/events/"))
        </div>
    </div>
    <span class="content-bottom">&nbsp;</span>
</div>